﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GoogleLogger
{
    public class DetectNet
    {
        public static bool detectDNS()
        {
            if (!System.Windows.Forms.SystemInformation.Network)
            {
                return false;
            }
            try
            {
                System.Net.IPHostEntry objIPHE  = System.Net.Dns.GetHostByName("www.google.com");
                return true;
            }
            catch (System.Exception e)
            {
                return false;            	
            }
            
        }

        public static bool detectSocket()
        {
            if (!System.Windows.Forms.SystemInformation.Network)
            {
                return false;
            }

            try
            {
                System.Net.Sockets.TcpClient clnt = new System.Net.Sockets.TcpClient("www.google.com", 80);
                clnt.Close();
                return true;
            }
            catch (System.Exception ex)
            {
                return false;
            } 
        }
    }
}
